package com.zhang.modules.auth.eneity;

import com.zhang.common.jpa.entity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.Set;

@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Entity(name = "SysAclRole")
public class Role extends BaseEntity {

    @Column(name = "name", nullable = false, length = 64)
    private String name;

    @Column(name = "description", length = 128)
    private String description;

    @Column(name = "code", nullable = false, length = 64)
    private String code;

    @Column(name = "type",  length = 32)
    private String type;

    @Column(name = "org_id",  length = 20)
    private String orgId;

    @Column(name = "property",  length = 32)
    private String property;

    @Column(name = "level",  length = 32)
    private String level;

    @Column(name = "status", nullable = false, length = 32)
    private String status;

    @ManyToMany
    @JoinTable(
            name = "sys_acl_role_permission",
            joinColumns = @JoinColumn(name = "role_id"),
            inverseJoinColumns ={
                    @JoinColumn(name = "permission_id",referencedColumnName = "id"),
                    @JoinColumn(name = "id",referencedColumnName = "id")
            }
    )
    private Set<Permission> permissions;

}